const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const InlineSourcePlugin = require('./plugins/InlineSourcePlugin')

/**
 * bundle [ˈbʌndl]: 捆，包，扎
 * build [bɪld]: 建筑;建造;创建;开发;逐渐增强
 */
module.exports = {
  mode: 'development',
  entry: './index.js',
  output: {
    filename: 'build.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"]
      },
    ]
  },

  plugins: [
    new MiniCssExtractPlugin({ filename: 'main.css'}),
    new InlineSourcePlugin({ match: /.(js|css)/}),
    new HtmlWebpackPlugin({template: './index.html' }),
  ]
}
